import React from 'react';
import { MainLayout, PageWrapper, Home, RoleAuthForm, Login, Demo, LifeCycle, DndDemo } from './AsyncBundles.jsx';

// 登录验证
function requireAuth(Layout, props) {
  if (false) { // 未登录
    return (<Redirect to="/login" />);
  } else {
    return (<Layout {...props} />);
  }
}

const routes = [ {
    path: '/login',
    exact: true,
    component: Login,
  }, {
    path: '/common',
    component: PageWrapper,
    routes: [{
      path: '/common/login',
      component: Demo,
    }]
  },
  {
  // component: (props) => { 
  //   return requireAuth(MainLayout, props)
  // },
  component:  MainLayout,
  exact: true,
  routes: [{
    path: '/',
    exact: true,
    component: Home,
  }, {
    path: '/RoleAuthForm',
    component: RoleAuthForm,
  }, {
    path: '/Demo',
    component: Demo,
  }, {
    path: '/LifeCycle',
    component: LifeCycle,
  }, {
    path: '/DndDemo',
    component: DndDemo,
  }]
}];

export default routes;

